From af70a8902bacd295ea98ee8ef66458b5699786fc Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 7 Mar 2003 06:13:09 +0000 Subject: [PATCH] Zero field counter between records. Cures bounds violation when more than about 50 records are shot in. --- gpsbabel/gcdb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpsbabel/gcdb.c b/gpsbabel/gcdb.c index 2dd5c7cd8..74be7d46a 100644 --- a/gpsbabel/gcdb.c +++ b/gpsbabel/gcdb.c @@ -210,6 +210,7 @@ gcdb_add_to_rec(struct dbrec *rec, char *fldname, gcdb_rectype rectype, void *da memcpy(&rec->dbfld[rec_cnt],tbuf, length); tbufp = tbuf; length += 4 + sizeof(struct dbfld) * rec_cnt; + rec_cnt = 0; return length; } @@ -252,7 +253,7 @@ gcdb_write_wpt(const waypoint *wpt) * We don't really know how many fields we'll have or how long * they'll be so we'll just lazily create a huge place to hold them. */ - rec = xcalloc(sizeof(*rec) + 5000, 1); + rec = xcalloc(sizeof(*rec) + 500, 1); gcdb_add_to_rec(rec, "gcna", RECTYPE_TEXT, wpt->description); gcdb_add_to_rec(rec, "gcid", RECTYPE_TEXT, wpt->shortname); -- 2.30.2